﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;
using Afa.Web.Mvc.Results;

namespace Afa.Web.Mvc.Controllers
{
    public abstract class ControllerBase: Controller
    { 
        #region 返回消息处理

        protected ActionResult CustomJson(object data)
        {
            return new NetJsonResult(data);
        }

        protected ActionResult DataJson(object data, string msg = "")
        {
            return new DataJson(data, msg);
        }

        protected ActionResult ErrorJson(string msg, int code = -1)
        {
            return new ErrorJson(code, msg);
        }

        protected ActionResult SuccJson(string msg = "")
        {
            if (string.IsNullOrWhiteSpace(msg))
            {
                return new SuccJson();
            }
            return new SuccJson(msg);
        }

        #endregion
    }
}
